/**
 * Copyright (C), 2015-2024, 开度
 * FileName: DataObject
 * Author:   ASUS
 * Date:     2024/1/19 9:55
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * Hezeyu           2024/1/19           1.0
 */
package com.example.demo.stream.common;

import com.example.demo.stream.common.enums.DataType;
import com.example.demo.stream.common.enums.OptType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.Data;

/**
 * 〈〉
 *
 * @author Hezeyu
 * @create 2024/1/19
 * @since 1.0.0
 */
@Data
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DataObject<T> {
    /**
     * Redis Stream 消息 ID
     */
    private String messageId;
    /**
     * 是什么对象类型（product，productLine,UserInfo）
     */
    @JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
    public DataType dataType;

    /**
     * 操作类型  1 新增 2 修改 3 删除
     */
    public OptType optType;

    /**
     * 主键
     */
    public Object primaryKey;

    /**
     * 操作值
     */
    public T data;

    public DataObject(String messageId, DataType dataType, OptType optType, Object primaryKey, T data) {
        this.messageId = messageId;
        this.dataType = dataType;
        this.optType = optType;
        this.primaryKey = primaryKey;
        this.data = data;
    }

    public DataObject() {

    }
}
